package wsz.email.service.impl;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import wsz.api.EmailService;
import wsz.email.service.MailService;

import javax.mail.MessagingException;

/**
 * 具体执行邮件逻辑
 * @author wsz
 * @date 2021/12/27 12:27
 **/
@Service
public class SendEmailServiceImpl implements EmailService {

    @Autowired
    private MailService mailService;

    /**
     * 发送邮箱验证码
     * @param email 目标邮箱
     * @param randonCode 验证码
     * @return
     */
    @Override
    public boolean sendCode(String email, String randonCode) {
        try {
            mailService.sendSimpleTextMail("验证码", randonCode, new String[]{email});
        } catch (MessagingException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}
